<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>推送列表</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/aui2/aui.css" />
    <style>
    	body{
    		background-color: #fff;
    	}
    	.submit-button{
            padding:0 20px;
            margin-bottom:20px;
        }
    </style>
</head>
<body>
    <div class="aui-content aui-margin-b-15">
        <ul id="pushlist" class="aui-list aui-list-in">
        </ul>
    </div>
    <div class="submit-button">
        <p><div class="aui-btn aui-btn-info aui-btn-block aui-btn-sm" onclick="confirm();">确定</div></p>    
    </div>
    
    <script id="li_temp" type="text/x-dot-template">
        {{for(var i=0;i<it.length;i++){ }}
        <li class="aui-list-item">
            <div class="aui-list-item-inner">
                <div class="aui-list-item-title">{{=it[i].name}}</div>
                <div class="aui-list-item-right">
                    <input type="checkbox" class="aui-checkbox" checked value={{=it[i].id}}>
                </div>
            </div>
        </li>
        {{ } }}
    </script>
</body>
<script src="../../script/doT.min.js"></script>
<script data-main="../../script/main" src="../../script/require.js"></script>
<script type="text/javascript">
    var token;
	apiready = function(){
        require(["zepto","common"],function(){
            $zb.prefs.getPrefs('token',function(ret){
                token = ret.value;
                sendAjax();
            })
        })
    };
    
    function sendAjax(){
        var s_data = {
            values:{
                token:token
            }
        }
        $zb.requestForData(s_data,'push','listClassesAndFansToPush',function(ret){
            if(ret.status=="OK"){
                $("#pushlist").html(doT.template($("#li_temp").text())(ret.data));
            }
        })
    }
    function confirm(){
        var ids = [];
        var names = [];
        $("input").each(function(){    
            if($(this).is(":checked")){    
                ids.push($(this).val());
                names.push($(this).parent().parent().find('.aui-list-item-title').html());    
            }    
        });
        api.execScript({
            frameName:'pushcourse_frm',
	        script: 'showlist('+JSON.stringify(ids)+','+JSON.stringify(names)+');'
        });
    }
    
</script>
</html>